package com.hackintosh.state.thread;

/**
 * @description：
 * @author：twislyn
 * @date：Created in 2021/05/23
 * @modified By：
 * @version: 1.0
 */
public class ThreadContext {
    private AbstractThreadState state;

    public AbstractThreadState getState() {
        return state;
    }

    public void setState(AbstractThreadState state) {
        this.state = state;
    }

    public ThreadContext(){
        this.state = new New();
    }

    public void start(){
        ((New)state).start(this);
    }

    public void getCPU() {
        ((Runnable)state).getCPU(this);
    }

    public void suspend() {
        ((Running)state).suspend(this);
    }

    public void resume() {
        ((Blocked)state).resume(this);
    }

    public void stop() {
        ((Running)state).stop(this);
    }
}
